<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/commons/taglibs.jsp" %>


<link rel="stylesheet" type="text/css" href="${ctx}/style/form_table.css">
<script src="${ctx}/includes/jquery.js" type="text/javascript"></script>
<script src="${ctx}/includes/jquery.form.js" type="text/javascript"></script>
<script src="${ctx}/js/My97DatePicker/WdatePicker.js" type="text/javascript"></script>
<script src="${ctx}/includes/jquery.validate.js" type="text/javascript"></script>
 
<script>
$(function(){
	$("#add_privateLog_form").validate({
		errorPlacement: function(error, element){
            $(element).next('.field_notice').hide();
            $(element).after(error);
       },
	   success: function(label){   
	       label.addClass('right').text('OK!');
	   },
	   rules:   
	   {
	    	title : {required : true},
	    	content : {required : true}
	   },   
	   message:{
	    	title : {required : '请输入内容'},
	    	content : {required : '请输入内容'}
	   }
	});  
});
</script>
<s:form id="add_privateLog_form" name="add_privateLog_form" method="post" action="privateLog/update.do" onsubmit="return false;" class="form-table">
	<s:token/>
	<s:hidden name="id"/>
	<table class="form-table">
		<tr>
			<th width="150">标题：</th>
			<td>
			<s:textfield key="title" title="请输入标题" cssClass="form-txtinput" id="title" size="50" maxlength="100" value="%{model.title}"/>
			</td>
		</tr>
		<tr>
			<th width="150">内容：</th>
			<td>
			<s:textarea rows="5" name="content" title="请输入内容" id="content" style="width: 400px;height: 100px" value="%{model.content}"></s:textarea>
			</td>
		</tr>
	</table>
	<div class="win-btn-panel" style="text-align: center;margin-top: 5px;">
		<input class="btn-short" type="button" name="subbtn" id="zxysp" value=" 提交 " title="点击提交" onClick="saveLog();"/>
	</div>
</s:form>
<script type="text/javascript">
function saveLog(){
	var v = $("#add_privateLog_form").valid();
	if(!v)return false;
	$('#add_privateLog_form').ajaxSubmit(resultHandler);
    return false;
    
}

function resultHandler(responseXML){
	var result = responseXML.getElementsByTagName("result")[0].firstChild.nodeValue;
	var message = responseXML.getElementsByTagName("error-message")[0].firstChild.nodeValue;
	var errorType = responseXML.getElementsByTagName("error-type")[0].firstChild.nodeValue;
	if(!eval(result)&&(errorType!=2)){
		alert(message);
	}
	else{
		var curDate = new Date(); 
		alert(message);
		parent.location.replace("${ctx}/privateLog/list.do?timsStamp=" + curDate.getTime());
	}
}
</script>
